// 模拟后端动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";

/**
 * roles：页面级别权限，这里模拟二种 "admin"、"common"
 * admin：管理员角色
 * common：普通角色
 */
const permissionRouter = {
  path: "/permission",
  meta: {
    title: "权限管理",
    icon: "ep:lollipop",
    rank: 10
  },
  children: [
    {
      path: "/permission/page/index",
      name: "PermissionPage",
      meta: {
        title: "页面权限",
        roles: ["admin", "common"]
      }
    },
    {
      path: "/permission/button",
      meta: {
        title: "按钮权限",
        roles: ["admin", "common"]
      },
      children: [
        {
          path: "/permission/button/router",
          component: "permission/button/index",
          name: "PermissionButtonRouter",
          meta: {
            title: "路由",
            auths: [
              "permission:btn:add",
              "permission:btn:edit",
              "permission:btn:delete"
            ]
          }
        },
        {
          path: "/permission/button/login",
          component: "permission/button/perms",
          name: "PermissionButtonLogin",
          meta: {
            title: "登录"
          }
        }
      ]
    }
  ]
};
const zhaoyRouter = {
  path: "/party",
  meta: {
    title: "党建",
    icon: "ep:lollipop",
    rank: 10
  },
  children: [
    {
      path: "/party/activity",
      name: "PartyActivity",
      meta: {
        title: "党建活动管理"
      }
    },
    {
      path: "/party/member",
      name: "PartyMember",
      meta: {
        title: "优秀党员风采"
      }
    },
    {
      path: "/party/structure",
      name: "PartyStructure",
      meta: {
        title: "五级五长治理体系"
      }
    },
    {
      path: "/party/log",
      name: "PartyLog",
      meta: {
        title: "六员服务日志"
      }
    },
    {
      path: "/party/propaganda",
      name: "PartyPropaganda",
      meta: {
        title: "精神文明宣传"
      }
    }
  ]
};
console.log(zhaoyRouter);

export default defineFakeRoute([
  {
    url: "/api/api/me/menus",
    method: "get",
    response: () => {
      return [permissionRouter, zhaoyRouter];
    }
  }
]);
